﻿namespace GameCore
{
    public class Singleton<T> where T : new()
    {
        private static readonly object objlock = new object();

        private static T instance;

        public static T Instance => GetInstance();

        public static T GetInstance()
        {
            if (instance == null)
            {
                lock (objlock)
                {
                    if (instance == null)
                    {
                        instance = new T();
                    }
                }
            }

            return instance;
        }
    }
}